﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using Dapper;
using Core;
using System.Threading;
using System.Net;

namespace DAL
{
    public class ReClassSignDAL : SyncBase<Model.ReClassSign>
    {
        static ReClassSignDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReClassSignDAL.addSQL = @"INSERT INTO [TempReClassSign](
                                                        [StudentID]
                                                       ,[QuestionID]
                                                       ,[SignContent]
                                                       ,[TeacherID]
                                                       ,[SignTime]
                                                       ,[SignPoint]
                                                       ,[LessionID]
                                                       ,[ClassId]
                                                       ,[ReType])VALUES(
                                                        @StudentID
                                                       ,@QuestionID
                                                       ,@SignContent
                                                       ,@TeacherID
                                                       ,@SignTime
                                                       ,@SignPoint
                                                       ,@LessionID
                                                       ,@ClassId
                                                       ,@ReType
                                                    );";
            ReClassSignDAL.tbName = "TempReClassSign";
            ReClassSignDAL.remoteUrl = "/Ayyfford/AddReClassSign";
            ReClassSignDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.Id + ",";
                        sb.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7},{8}),",
                            t.StudentID.NullNumber(), t.QuestionID.NullNumber(), t.SignContent.NullNumber(), t.TeacherID.NullNumber(), t.SignTime.NullDate(), t.SignPoint.NullNumber(), t.LessionID.NullNumber(), t.ClassId.NullNumber(), t.ReType.NullNumber());

                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReClassSign t)
        {
            SyncBase<Model.ReClassSign>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReClassSign>.AsyncData();
        }
    }
}
